import 'package:flutter/material.dart';
import 'package:flutterdemo/day02/01_statelesswidget.dart';
void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      // 启动要显示的界面
      home: HomePage(),
    );
  }
}

class HomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("图标组件示例"),
      ),
      body: JKHomeContent(),
      floatingActionButton: FloatingActionButton(
        child: Icon(Icons.add),
        onPressed: () {
          print("FloatingActionButton Click");
        },
      ),
    );
  }
}

class JKHomeContent extends StatelessWidget {
  final imageUrl = 'https://tva1.sinaimg.cn/large/006y8mN6gy1g7aa03bmfpj3069069mx8.jpg';
  final nameTextEditingController = TextEditingController();
  final passwordTextEditingController = TextEditingController();
  @override
  Widget build(BuildContext context) {
    return Theme(
      data: ThemeData(
          primaryColor: Colors.red
      ),
      child: Padding(
        padding: const EdgeInsets.all(8.0),
        child: Column(
          children: [
            TextField(
              controller: nameTextEditingController,
              decoration: InputDecoration(
                  labelText: "username",
                  icon: Icon(Icons.favorite),
                  hintText: "请输入用户名",
                  // OutlineInputBorder
                  // InputBorder.none
                  border: OutlineInputBorder()
              ),
              onChanged: (value) {
                print("$value");
              },
              onSubmitted: (value) {
                print("提交的值：$value");
              },
              // 输入不可见
              obscureText: true,

            ),
            SizedBox(height: 16,),
            TextField(
              controller: passwordTextEditingController,
              decoration: InputDecoration(
                  labelText: "password",
                  icon: Icon(Icons.favorite),
                  hintText: "请输入密码",
                  border: OutlineInputBorder()
              ),
            ),
            SizedBox(
              height: 20,
            ),
            Container(
              width: double.infinity,
              height: 44,
              child: FlatButton(
                child: Text("登 录", style: TextStyle(fontSize: 20.0, color: Colors.white),),
                color: Colors.blue,
                onPressed: () {
                  final username = nameTextEditingController.text;
                  final password = passwordTextEditingController.text;
                  print("登录 click：账号是：$username 密码是：$password");
                },
              ),
            )
          ],
        ),
      ),
    );
  }
}



